<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang = "en">

<head>

<link rel="shortcut icon" href="http://algs4.cs.princeton.edu/favicon.ico">
<link rel="stylesheet"    href="http://algs4.cs.princeton.edu/java.css" type="text/css">

<title>FibonacciMinPQ.java</title>

<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="Robert Sedgewick and Kevin Wayne">
<meta NAME="DESCRIPTION" CONTENT="FibonacciMinPQ code in Java">
<meta NAME="TITLE" CONTENT="FibonacciMinPQ code in Java">
<meta NAME="KEYWORDS" CONTENT="FibonacciMinPQ,java,programming,computer science,algorithm,data structure,program,code">
<meta NAME="ROBOTS" CONTENT="INDEX,FOLLOW">

</head>


<body>
<center><h1>FibonacciMinPQ.java</h1></center><p><br>

Below is the syntax highlighted version of <a href = "FibonacciMinPQ.java">FibonacciMinPQ.java</a>.
<p><br>

<!-- Generator: GNU source-highlight 3.1.6
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span class="comment">/******************************************************************************</span>
<span class="comment"> *  Compilation: javac FibonacciMinPQ.java</span>
<span class="comment"> *  Execution:</span>
<span class="comment"> *</span>
<span class="comment"> *  A Fibonacci heap.</span>
<span class="comment"> *</span>
<span class="comment"> ******************************************************************************/</span>

<span class="preproc">package</span><span class="normal"> edu</span><span class="symbol">.</span><span class="normal">princeton</span><span class="symbol">.</span><span class="normal">cs</span><span class="symbol">.</span><span class="normal">algs4</span><span class="symbol">;</span>

<span class="preproc">import</span><span class="normal"> java</span><span class="symbol">.</span><span class="normal">util</span><span class="symbol">.</span><span class="normal">Iterator</span><span class="symbol">;</span>
<span class="preproc">import</span><span class="normal"> java</span><span class="symbol">.</span><span class="normal">util</span><span class="symbol">.</span><span class="normal">HashMap</span><span class="symbol">;</span>
<span class="preproc">import</span><span class="normal"> java</span><span class="symbol">.</span><span class="normal">util</span><span class="symbol">.</span><span class="normal">NoSuchElementException</span><span class="symbol">;</span>
<span class="preproc">import</span><span class="normal"> java</span><span class="symbol">.</span><span class="normal">util</span><span class="symbol">.</span><span class="normal">Comparator</span><span class="symbol">;</span>

<span class="comment">/*</span>
<span class="comment"> *  The FibonacciMinPQ class represents a priority queue of generic keys.</span>
<span class="comment"> *  It supports the usual insert and delete-the-minimum operations, </span>
<span class="comment"> *  along with the merging of two heaps together.</span>
<span class="comment"> *  It also supports methods for peeking at the minimum key,</span>
<span class="comment"> *  testing if the priority queue is empty, and iterating through</span>
<span class="comment"> *  the keys.</span>
<span class="comment"> *  It is possible to build the priority queue using a Comparator.</span>
<span class="comment"> *  If not, the natural order relation between the keys will be used.</span>
<span class="comment"> *  </span>
<span class="comment"> *  This implementation uses a Fibonacci heap.</span>
<span class="comment"> *  The delete-the-minimum operation takes amortized logarithmic time.</span>
<span class="comment"> *  The insert, min-key, is-empty, size, union and constructor take constant time.</span>
<span class="comment"> *</span>
<span class="comment"> *  @author Tristan Claverie</span>
<span class="comment"> */</span>
<span class="keyword">public</span><span class="normal"> </span><span class="keyword">class</span><span class="normal"> </span><span class="classname">FibonacciMinPQ</span><span class="symbol">&lt;</span><span class="normal">Key</span><span class="symbol">&gt;</span><span class="normal"> </span><span class="keyword">implements</span><span class="normal"> Iterable</span><span class="symbol">&lt;</span><span class="normal">Key</span><span class="symbol">&gt;</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="usertype">Node</span><span class="normal"> head</span><span class="symbol">;</span><span class="normal">					</span><span class="comment">//Head of the circular root list</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="usertype">Node</span><span class="normal"> min</span><span class="symbol">;</span><span class="normal">					</span><span class="comment">//Minimum Node of the root list</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="type">int</span><span class="normal"> size</span><span class="symbol">;</span><span class="normal">					</span><span class="comment">//Number of keys in the heap</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">final</span><span class="normal"> </span><span class="usertype">Comparator&lt;Key&gt;</span><span class="normal"> comp</span><span class="symbol">;</span><span class="normal">	</span><span class="comment">//Comparator over the keys</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="usertype">HashMap&lt;Integer, Node&gt;</span><span class="normal"> table </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> HashMap</span><span class="symbol">&lt;</span><span class="normal">Integer</span><span class="symbol">,</span><span class="normal"> Node</span><span class="symbol">&gt;();</span><span class="normal"> </span><span class="comment">//Used for the consolidate operation</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">//Represents a Node of a tree</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">class</span><span class="normal"> </span><span class="classname">Node</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="usertype">Key</span><span class="normal"> key</span><span class="symbol">;</span><span class="normal">						</span><span class="comment">//Key of this Node</span>
<span class="normal">		</span><span class="type">int</span><span class="normal"> order</span><span class="symbol">;</span><span class="normal">						</span><span class="comment">//Order of the tree rooted by this Node</span>
<span class="normal">		</span><span class="usertype">Node</span><span class="normal"> prev</span><span class="symbol">,</span><span class="normal"> next</span><span class="symbol">;</span><span class="normal">				</span><span class="comment">//Siblings of this Node</span>
<span class="normal">		</span><span class="usertype">Node</span><span class="normal"> child</span><span class="symbol">;</span><span class="normal">						</span><span class="comment">//Child of this Node</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">/**</span>
<span class="comment">	 * Initializes an empty priority queue</span>
<span class="comment">	 * Worst case is O(1)</span>
<span class="comment">	 * </span><span class="type">@param</span><span class="comment"> C a Comparator over the Keys</span>
<span class="comment">	 */</span>
<span class="normal">	</span><span class="keyword">public</span><span class="normal"> </span><span class="function">FibonacciMinPQ</span><span class="symbol">(</span><span class="usertype">Comparator&lt;Key&gt;</span><span class="normal"> C</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		comp </span><span class="symbol">=</span><span class="normal"> C</span><span class="symbol">;</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">    </span><span class="comment">/**</span>
<span class="comment">     * Initializes an empty priority queue</span>
<span class="comment">     * Worst case is O(1)</span>
<span class="comment">     */</span>
<span class="normal">	</span><span class="keyword">public</span><span class="normal"> </span><span class="function">FibonacciMinPQ</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		comp </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">MyComparator</span><span class="symbol">();</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">/**</span>
<span class="comment">	 * Initializes a priority queue with given keys</span>
<span class="comment">	 * Worst case is O(n)</span>
<span class="comment">	 * </span><span class="type">@param</span><span class="comment"> a an array of keys</span>
<span class="comment">	 */</span>
<span class="normal">	</span><span class="keyword">public</span><span class="normal"> </span><span class="function">FibonacciMinPQ</span><span class="symbol">(</span><span class="normal">Key</span><span class="symbol">[]</span><span class="normal"> a</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		comp </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">MyComparator</span><span class="symbol">();</span>
<span class="normal">		</span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">Key</span><span class="normal"> k </span><span class="symbol">:</span><span class="normal"> a</span><span class="symbol">)</span><span class="normal"> </span><span class="function">insert</span><span class="symbol">(</span><span class="normal">k</span><span class="symbol">);</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">/**</span>
<span class="comment">	 * Initializes a priority queue with given keys</span>
<span class="comment">	 * Worst case is O(n)</span>
<span class="comment">	 * </span><span class="type">@param</span><span class="comment"> C a comparator over the keys</span>
<span class="comment">	 * </span><span class="type">@param</span><span class="comment"> a an array of keys</span>
<span class="comment">	 */</span>
<span class="normal">	</span><span class="keyword">public</span><span class="normal"> </span><span class="function">FibonacciMinPQ</span><span class="symbol">(</span><span class="usertype">Comparator&lt;Key&gt;</span><span class="normal"> C</span><span class="symbol">,</span><span class="normal"> Key</span><span class="symbol">[]</span><span class="normal"> a</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		comp </span><span class="symbol">=</span><span class="normal"> C</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">Key</span><span class="normal"> k </span><span class="symbol">:</span><span class="normal"> a</span><span class="symbol">)</span><span class="normal"> </span><span class="function">insert</span><span class="symbol">(</span><span class="normal">k</span><span class="symbol">);</span>
<span class="normal">	</span><span class="cbracket">}</span>

<span class="normal">	</span><span class="comment">/**</span>
<span class="comment">	 * Whether the priority queue is empty</span>
<span class="comment">	 * Worst case is O(1)</span>
<span class="comment">	 * </span><span class="type">@return</span><span class="comment"> true if the priority queue is empty, false if not</span>
<span class="comment">	 */</span>
<span class="normal">	</span><span class="keyword">public</span><span class="normal"> </span><span class="type">boolean</span><span class="normal"> </span><span class="function">isEmpty</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="keyword">return</span><span class="normal"> size </span><span class="symbol">==</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span>
<span class="normal">	</span><span class="cbracket">}</span>

<span class="normal">	</span><span class="comment">/**</span>
<span class="comment">	 * Number of elements currently on the priority queue</span>
<span class="comment">	 * Worst case is O(1)</span>
<span class="comment">	 * </span><span class="type">@return</span><span class="comment"> the number of elements on the priority queue</span>
<span class="comment">	 */</span>
<span class="normal">	</span><span class="keyword">public</span><span class="normal"> </span><span class="type">int</span><span class="normal"> </span><span class="function">size</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="keyword">return</span><span class="normal"> size</span><span class="symbol">;</span>
<span class="normal">	</span><span class="cbracket">}</span>

<span class="normal">	</span><span class="comment">/**</span>
<span class="comment">	 * Insert a key in the queue</span>
<span class="comment">	 * Worst case is O(1)</span>
<span class="comment">	 * </span><span class="type">@param</span><span class="comment"> key a Key</span>
<span class="comment">	 */</span>
<span class="normal">	</span><span class="keyword">public</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">insert</span><span class="symbol">(</span><span class="usertype">Key</span><span class="normal"> key</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="usertype">Node</span><span class="normal"> x </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">Node</span><span class="symbol">();</span>
<span class="normal">		x</span><span class="symbol">.</span><span class="normal">key </span><span class="symbol">=</span><span class="normal"> key</span><span class="symbol">;</span>
<span class="normal">		size</span><span class="symbol">++;</span>
<span class="normal">		head </span><span class="symbol">=</span><span class="normal"> </span><span class="function">insert</span><span class="symbol">(</span><span class="normal">x</span><span class="symbol">,</span><span class="normal"> head</span><span class="symbol">);</span>
<span class="normal">		</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">min </span><span class="symbol">==</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">)</span><span class="normal"> min </span><span class="symbol">=</span><span class="normal"> head</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">else</span><span class="normal"> 			 min </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="function">greater</span><span class="symbol">(</span><span class="normal">min</span><span class="symbol">.</span><span class="normal">key</span><span class="symbol">,</span><span class="normal"> key</span><span class="symbol">))</span><span class="normal"> </span><span class="symbol">?</span><span class="normal"> head </span><span class="symbol">:</span><span class="normal"> min</span><span class="symbol">;</span>
<span class="normal">	</span><span class="cbracket">}</span>

<span class="normal">	</span><span class="comment">/**</span>
<span class="comment">	 * Gets the minimum key currently in the queue</span>
<span class="comment">	 * Worst case is O(1)</span>
<span class="comment">	 * </span><span class="type">@throws</span><span class="comment"> java.util.NoSuchElementException if the priority queue is empty</span>
<span class="comment">	 * </span><span class="type">@return</span><span class="comment"> the minimum key currently in the priority queue</span>
<span class="comment">	 */</span>
<span class="normal">	</span><span class="keyword">public</span><span class="normal"> </span><span class="usertype">Key</span><span class="normal"> </span><span class="function">minKey</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function">isEmpty</span><span class="symbol">())</span><span class="normal"> </span><span class="keyword">throw</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">NoSuchElementException</span><span class="symbol">(</span><span class="string">"Priority queue is empty"</span><span class="symbol">);</span>
<span class="normal">		</span><span class="keyword">return</span><span class="normal"> min</span><span class="symbol">.</span><span class="normal">key</span><span class="symbol">;</span>
<span class="normal">	</span><span class="cbracket">}</span>

<span class="normal">	</span><span class="comment">/**</span>
<span class="comment">	 * Deletes the minimum key</span>
<span class="comment">	 * Worst case is O(log(n)) (amortized)</span>
<span class="comment">	 * </span><span class="type">@throws</span><span class="comment"> java.util.NoSuchElementException if the priority queue is empty</span>
<span class="comment">	 * </span><span class="type">@return</span><span class="comment"> the minimum key</span>
<span class="comment">	 */</span>
<span class="normal">	</span><span class="keyword">public</span><span class="normal"> </span><span class="usertype">Key</span><span class="normal"> </span><span class="function">delMin</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function">isEmpty</span><span class="symbol">())</span><span class="normal"> </span><span class="keyword">throw</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">NoSuchElementException</span><span class="symbol">(</span><span class="string">"Priority queue is empty"</span><span class="symbol">);</span>
<span class="normal">		head </span><span class="symbol">=</span><span class="normal"> </span><span class="function">cut</span><span class="symbol">(</span><span class="normal">min</span><span class="symbol">,</span><span class="normal"> head</span><span class="symbol">);</span>
<span class="normal">		</span><span class="usertype">Node</span><span class="normal"> x </span><span class="symbol">=</span><span class="normal"> min</span><span class="symbol">.</span><span class="normal">child</span><span class="symbol">;</span>
<span class="normal">		</span><span class="usertype">Key</span><span class="normal"> key </span><span class="symbol">=</span><span class="normal"> min</span><span class="symbol">.</span><span class="normal">key</span><span class="symbol">;</span>
<span class="normal">		min</span><span class="symbol">.</span><span class="normal">key </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">x </span><span class="symbol">!=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			head </span><span class="symbol">=</span><span class="normal"> </span><span class="function">meld</span><span class="symbol">(</span><span class="normal">head</span><span class="symbol">,</span><span class="normal"> x</span><span class="symbol">);</span>
<span class="normal">			min</span><span class="symbol">.</span><span class="normal">child </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="normal">		size</span><span class="symbol">--;</span>
<span class="normal">		</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(!</span><span class="function">isEmpty</span><span class="symbol">())</span><span class="normal"> </span><span class="function">consolidate</span><span class="symbol">();</span>
<span class="normal">		</span><span class="keyword">else</span><span class="normal"> 			min </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">return</span><span class="normal"> key</span><span class="symbol">;</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">/**</span>
<span class="comment">	 * Merges two heaps together</span>
<span class="comment">	 * This operation is destructive</span>
<span class="comment">	 * Worst case is O(1)</span>
<span class="comment">	 * </span><span class="type">@param</span><span class="comment"> that a Fibonacci heap</span>
<span class="comment">	 * </span><span class="type">@return</span><span class="comment"> the union of the two heaps</span>
<span class="comment">	 */</span>
<span class="normal">	</span><span class="keyword">public</span><span class="normal"> </span><span class="usertype">FibonacciMinPQ&lt;Key&gt; union(FibonacciMinPQ&lt;Key&gt;</span><span class="normal"> that</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="keyword">this</span><span class="symbol">.</span><span class="normal">head </span><span class="symbol">=</span><span class="normal"> </span><span class="function">meld</span><span class="symbol">(</span><span class="normal">head</span><span class="symbol">,</span><span class="normal"> that</span><span class="symbol">.</span><span class="normal">head</span><span class="symbol">);</span>
<span class="normal">		</span><span class="keyword">this</span><span class="symbol">.</span><span class="normal">min </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="function">greater</span><span class="symbol">(</span><span class="keyword">this</span><span class="symbol">.</span><span class="normal">min</span><span class="symbol">.</span><span class="normal">key</span><span class="symbol">,</span><span class="normal"> that</span><span class="symbol">.</span><span class="normal">min</span><span class="symbol">.</span><span class="normal">key</span><span class="symbol">))</span><span class="normal"> </span><span class="symbol">?</span><span class="normal"> that</span><span class="symbol">.</span><span class="normal">min </span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">this</span><span class="symbol">.</span><span class="normal">min</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">this</span><span class="symbol">.</span><span class="normal">size </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">this</span><span class="symbol">.</span><span class="normal">size</span><span class="symbol">+</span><span class="normal">that</span><span class="symbol">.</span><span class="normal">size</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">this</span><span class="symbol">;</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">/*************************************</span>
<span class="comment">	 * General helper functions</span>
<span class="comment">	 ************************************/</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">//Compares two keys</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="type">boolean</span><span class="normal"> </span><span class="function">greater</span><span class="symbol">(</span><span class="usertype">Key</span><span class="normal"> n</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">Key</span><span class="normal"> m</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">n </span><span class="symbol">==</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">)</span><span class="normal"> </span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">false</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">m </span><span class="symbol">==</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">)</span><span class="normal"> </span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">true</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">return</span><span class="normal"> comp</span><span class="symbol">.</span><span class="function">compare</span><span class="symbol">(</span><span class="normal">n</span><span class="symbol">,</span><span class="normal">m</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">&gt;</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">//Assuming root1 holds a greater key than root2, root2 becomes the new root</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">link</span><span class="symbol">(</span><span class="usertype">Node</span><span class="normal"> root1</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">Node</span><span class="normal"> root2</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		root2</span><span class="symbol">.</span><span class="normal">child </span><span class="symbol">=</span><span class="normal"> </span><span class="function">insert</span><span class="symbol">(</span><span class="normal">root1</span><span class="symbol">,</span><span class="normal"> root2</span><span class="symbol">.</span><span class="normal">child</span><span class="symbol">);</span>
<span class="normal">		root2</span><span class="symbol">.</span><span class="normal">order</span><span class="symbol">++;</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">/*************************************</span>
<span class="comment">	 * Function for consolidating all trees in the root list</span>
<span class="comment">	 ************************************/</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">//Coalesce the roots, thus reshapes the tree</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">consolidate</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		table</span><span class="symbol">.</span><span class="function">clear</span><span class="symbol">();</span>
<span class="normal">		</span><span class="usertype">Node</span><span class="normal"> x </span><span class="symbol">=</span><span class="normal"> head</span><span class="symbol">;</span>
<span class="normal">		</span><span class="type">int</span><span class="normal"> maxOrder </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span>
<span class="normal">		min </span><span class="symbol">=</span><span class="normal"> head</span><span class="symbol">;</span>
<span class="normal">		</span><span class="usertype">Node</span><span class="normal"> y </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span><span class="normal"> </span><span class="usertype">Node</span><span class="normal"> z </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">do</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			y </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">;</span>
<span class="normal">			x </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">.</span><span class="normal">next</span><span class="symbol">;</span>
<span class="normal">			z </span><span class="symbol">=</span><span class="normal"> table</span><span class="symbol">.</span><span class="function">get</span><span class="symbol">(</span><span class="normal">y</span><span class="symbol">.</span><span class="normal">order</span><span class="symbol">);</span>
<span class="normal">			</span><span class="keyword">while</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">z </span><span class="symbol">!=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">				table</span><span class="symbol">.</span><span class="function">remove</span><span class="symbol">(</span><span class="normal">y</span><span class="symbol">.</span><span class="normal">order</span><span class="symbol">);</span>
<span class="normal">				</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function">greater</span><span class="symbol">(</span><span class="normal">y</span><span class="symbol">.</span><span class="normal">key</span><span class="symbol">,</span><span class="normal"> z</span><span class="symbol">.</span><span class="normal">key</span><span class="symbol">))</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">					</span><span class="function">link</span><span class="symbol">(</span><span class="normal">y</span><span class="symbol">,</span><span class="normal"> z</span><span class="symbol">);</span>
<span class="normal">					y </span><span class="symbol">=</span><span class="normal"> z</span><span class="symbol">;</span>
<span class="normal">				</span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">					</span><span class="function">link</span><span class="symbol">(</span><span class="normal">z</span><span class="symbol">,</span><span class="normal"> y</span><span class="symbol">);</span>
<span class="normal">				</span><span class="cbracket">}</span>
<span class="normal">				z </span><span class="symbol">=</span><span class="normal"> table</span><span class="symbol">.</span><span class="function">get</span><span class="symbol">(</span><span class="normal">y</span><span class="symbol">.</span><span class="normal">order</span><span class="symbol">);</span>
<span class="normal">			</span><span class="cbracket">}</span>
<span class="normal">			table</span><span class="symbol">.</span><span class="function">put</span><span class="symbol">(</span><span class="normal">y</span><span class="symbol">.</span><span class="normal">order</span><span class="symbol">,</span><span class="normal"> y</span><span class="symbol">);</span>
<span class="normal">			</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">y</span><span class="symbol">.</span><span class="normal">order </span><span class="symbol">&gt;</span><span class="normal"> maxOrder</span><span class="symbol">)</span><span class="normal"> maxOrder </span><span class="symbol">=</span><span class="normal"> y</span><span class="symbol">.</span><span class="normal">order</span><span class="symbol">;</span>
<span class="normal">		</span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">while</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">x </span><span class="symbol">!=</span><span class="normal"> head</span><span class="symbol">);</span>
<span class="normal">		head </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">Node</span><span class="normal"> n </span><span class="symbol">:</span><span class="normal"> table</span><span class="symbol">.</span><span class="function">values</span><span class="symbol">())</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">n </span><span class="symbol">!=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">				min </span><span class="symbol">=</span><span class="normal"> </span><span class="function">greater</span><span class="symbol">(</span><span class="normal">min</span><span class="symbol">.</span><span class="normal">key</span><span class="symbol">,</span><span class="normal"> n</span><span class="symbol">.</span><span class="normal">key</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">?</span><span class="normal"> n </span><span class="symbol">:</span><span class="normal"> min</span><span class="symbol">;</span>
<span class="normal">				head </span><span class="symbol">=</span><span class="normal"> </span><span class="function">insert</span><span class="symbol">(</span><span class="normal">n</span><span class="symbol">,</span><span class="normal"> head</span><span class="symbol">);</span>
<span class="normal">			</span><span class="cbracket">}</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">/*************************************</span>
<span class="comment">	 * General helper functions for manipulating circular lists</span>
<span class="comment">	 ************************************/</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">//Inserts a Node in a circular list containing head, returns a new head</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="usertype">Node</span><span class="normal"> </span><span class="function">insert</span><span class="symbol">(</span><span class="usertype">Node</span><span class="normal"> x</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">Node</span><span class="normal"> head</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">head </span><span class="symbol">==</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			x</span><span class="symbol">.</span><span class="normal">prev </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">;</span>
<span class="normal">			x</span><span class="symbol">.</span><span class="normal">next </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">;</span>
<span class="normal">		</span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			head</span><span class="symbol">.</span><span class="normal">prev</span><span class="symbol">.</span><span class="normal">next </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">;</span>
<span class="normal">			x</span><span class="symbol">.</span><span class="normal">next </span><span class="symbol">=</span><span class="normal"> head</span><span class="symbol">;</span>
<span class="normal">			x</span><span class="symbol">.</span><span class="normal">prev </span><span class="symbol">=</span><span class="normal"> head</span><span class="symbol">.</span><span class="normal">prev</span><span class="symbol">;</span>
<span class="normal">			head</span><span class="symbol">.</span><span class="normal">prev </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">;</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="normal">		</span><span class="keyword">return</span><span class="normal"> x</span><span class="symbol">;</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">//Removes a tree from the list defined by the head pointer</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="usertype">Node</span><span class="normal"> </span><span class="function">cut</span><span class="symbol">(</span><span class="usertype">Node</span><span class="normal"> x</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">Node</span><span class="normal"> head</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">x</span><span class="symbol">.</span><span class="normal">next </span><span class="symbol">==</span><span class="normal"> x</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			x</span><span class="symbol">.</span><span class="normal">next </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">			x</span><span class="symbol">.</span><span class="normal">prev </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">			</span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">		</span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			x</span><span class="symbol">.</span><span class="normal">next</span><span class="symbol">.</span><span class="normal">prev </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">.</span><span class="normal">prev</span><span class="symbol">;</span>
<span class="normal">			x</span><span class="symbol">.</span><span class="normal">prev</span><span class="symbol">.</span><span class="normal">next </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">.</span><span class="normal">next</span><span class="symbol">;</span>
<span class="normal">			</span><span class="usertype">Node</span><span class="normal"> res </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">.</span><span class="normal">next</span><span class="symbol">;</span>
<span class="normal">			x</span><span class="symbol">.</span><span class="normal">next </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">			x</span><span class="symbol">.</span><span class="normal">prev </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">			</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">head </span><span class="symbol">==</span><span class="normal"> x</span><span class="symbol">)</span><span class="normal">  </span><span class="keyword">return</span><span class="normal"> res</span><span class="symbol">;</span>
<span class="normal">			</span><span class="keyword">else</span><span class="normal"> 			</span><span class="keyword">return</span><span class="normal"> head</span><span class="symbol">;</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">//Merges two root lists together</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="usertype">Node</span><span class="normal"> </span><span class="function">meld</span><span class="symbol">(</span><span class="usertype">Node</span><span class="normal"> x</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">Node</span><span class="normal"> y</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">x </span><span class="symbol">==</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">)</span><span class="normal"> </span><span class="keyword">return</span><span class="normal"> y</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">y </span><span class="symbol">==</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">)</span><span class="normal"> </span><span class="keyword">return</span><span class="normal"> x</span><span class="symbol">;</span>
<span class="normal">		x</span><span class="symbol">.</span><span class="normal">prev</span><span class="symbol">.</span><span class="normal">next </span><span class="symbol">=</span><span class="normal"> y</span><span class="symbol">.</span><span class="normal">next</span><span class="symbol">;</span>
<span class="normal">		y</span><span class="symbol">.</span><span class="normal">next</span><span class="symbol">.</span><span class="normal">prev </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">.</span><span class="normal">prev</span><span class="symbol">;</span>
<span class="normal">		x</span><span class="symbol">.</span><span class="normal">prev </span><span class="symbol">=</span><span class="normal"> y</span><span class="symbol">;</span>
<span class="normal">		y</span><span class="symbol">.</span><span class="normal">next </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">;</span>
<span class="normal">		</span><span class="keyword">return</span><span class="normal"> x</span><span class="symbol">;</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">/*************************************</span>
<span class="comment">	 * Iterator</span>
<span class="comment">	 ************************************/</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">/**</span>
<span class="comment">	 * Gets an Iterator over the Keys in the priority queue in ascending order</span>
<span class="comment">	 * The Iterator does not implement the remove() method</span>
<span class="comment">	 * iterator() : Worst case is O(n)</span>
<span class="comment">	 * next() : 	Worst case is O(log(n)) (amortized)</span>
<span class="comment">	 * hasNext() : 	Worst case is O(1)</span>
<span class="comment">	 * </span><span class="type">@return</span><span class="comment"> an Iterator over the Keys in the priority queue in ascending order</span>
<span class="comment">	 */</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="keyword">public</span><span class="normal"> </span><span class="usertype">Iterator&lt;Key&gt;</span><span class="normal"> </span><span class="function">iterator</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">MyIterator</span><span class="symbol">();</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">class</span><span class="normal"> </span><span class="classname">MyIterator</span><span class="normal"> </span><span class="keyword">implements</span><span class="normal"> Iterator</span><span class="symbol">&lt;</span><span class="normal">Key</span><span class="symbol">&gt;</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		</span><span class="keyword">private</span><span class="normal"> </span><span class="usertype">FibonacciMinPQ&lt;Key&gt;</span><span class="normal"> copy</span><span class="symbol">;</span>
<span class="normal">		</span>
<span class="normal">		</span>
<span class="normal">		</span><span class="comment">//Constructor takes linear time</span>
<span class="normal">		</span><span class="keyword">public</span><span class="normal"> </span><span class="function">MyIterator</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			copy </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> FibonacciMinPQ</span><span class="symbol">&lt;</span><span class="normal">Key</span><span class="symbol">&gt;(</span><span class="normal">comp</span><span class="symbol">);</span>
<span class="normal">			</span><span class="function">insertAll</span><span class="symbol">(</span><span class="normal">head</span><span class="symbol">);</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="normal">		</span>
<span class="normal">		</span><span class="keyword">private</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">insertAll</span><span class="symbol">(</span><span class="usertype">Node</span><span class="normal"> head</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">head </span><span class="symbol">==</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">)</span><span class="normal"> </span><span class="keyword">return</span><span class="symbol">;</span>
<span class="normal">			</span><span class="usertype">Node</span><span class="normal"> x </span><span class="symbol">=</span><span class="normal"> head</span><span class="symbol">;</span>
<span class="normal">			</span><span class="keyword">do</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">				copy</span><span class="symbol">.</span><span class="function">insert</span><span class="symbol">(</span><span class="normal">x</span><span class="symbol">.</span><span class="normal">key</span><span class="symbol">);</span>
<span class="normal">				</span><span class="function">insertAll</span><span class="symbol">(</span><span class="normal">x</span><span class="symbol">.</span><span class="normal">child</span><span class="symbol">);</span>
<span class="normal">				x </span><span class="symbol">=</span><span class="normal"> x</span><span class="symbol">.</span><span class="normal">next</span><span class="symbol">;</span>
<span class="normal">			</span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">while</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">x </span><span class="symbol">!=</span><span class="normal"> head</span><span class="symbol">);</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="normal">		</span>
<span class="normal">		</span><span class="keyword">public</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">remove</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="keyword">throw</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">UnsupportedOperationException</span><span class="symbol">();</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="normal">		</span>
<span class="normal">		</span><span class="keyword">public</span><span class="normal"> </span><span class="type">boolean</span><span class="normal"> </span><span class="function">hasNext</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="keyword">return</span><span class="normal"> </span><span class="symbol">!</span><span class="normal">copy</span><span class="symbol">.</span><span class="function">isEmpty</span><span class="symbol">();</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="normal">		</span>
<span class="normal">		</span><span class="comment">//Takes amortized logarithmic time</span>
<span class="normal">		</span><span class="keyword">public</span><span class="normal"> </span><span class="usertype">Key</span><span class="normal"> </span><span class="function">next</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(!</span><span class="function">hasNext</span><span class="symbol">())</span><span class="normal"> </span><span class="keyword">throw</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">NoSuchElementException</span><span class="symbol">();</span>
<span class="normal">			</span><span class="keyword">return</span><span class="normal"> copy</span><span class="symbol">.</span><span class="function">delMin</span><span class="symbol">();</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">/*************************************</span>
<span class="comment">	 * Comparator</span>
<span class="comment">	 ************************************/</span>
<span class="normal">	</span>
<span class="normal">	</span><span class="comment">//default Comparator</span>
<span class="normal">	</span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">class</span><span class="normal"> </span><span class="classname">MyComparator</span><span class="normal"> </span><span class="keyword">implements</span><span class="normal"> Comparator</span><span class="symbol">&lt;</span><span class="normal">Key</span><span class="symbol">&gt;</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">		@Override</span>
<span class="normal">		</span><span class="keyword">public</span><span class="normal"> </span><span class="type">int</span><span class="normal"> </span><span class="function">compare</span><span class="symbol">(</span><span class="usertype">Key</span><span class="normal"> key1</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">Key</span><span class="normal"> key2</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="keyword">return</span><span class="normal"> </span><span class="symbol">((</span><span class="normal">Comparable</span><span class="symbol">&lt;</span><span class="normal">Key</span><span class="symbol">&gt;)</span><span class="normal"> key1</span><span class="symbol">).</span><span class="function">compareTo</span><span class="symbol">(</span><span class="normal">key2</span><span class="symbol">);</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="normal">	</span>
<span class="cbracket">}</span>

<span class="comment">/******************************************************************************</span>
<span class="comment"> *  Copyright 2002-2015, Robert Sedgewick and Kevin Wayne.</span>
<span class="comment"> *</span>
<span class="comment"> *  This file is part of algs4.jar, which accompanies the textbook</span>
<span class="comment"> *</span>
<span class="comment"> *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,</span>
<span class="comment"> *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.</span>
<span class="comment"> *      </span><span class="url">http://algs4.cs.princeton.edu</span>
<span class="comment"> *</span>
<span class="comment"> *</span>
<span class="comment"> *  algs4.jar is free software: you can redistribute it and/or modify</span>
<span class="comment"> *  it under the terms of the GNU General Public License as published by</span>
<span class="comment"> *  the Free Software Foundation, either version 3 of the License, or</span>
<span class="comment"> *  (at your option) any later version.</span>
<span class="comment"> *</span>
<span class="comment"> *  algs4.jar is distributed in the hope that it will be useful,</span>
<span class="comment"> *  but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="comment"> *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span class="comment"> *  GNU General Public License for more details.</span>
<span class="comment"> *</span>
<span class="comment"> *  You should have received a copy of the GNU General Public License</span>
<span class="comment"> *  along with algs4.jar.  If not, see </span><span class="url">http://www.gnu.org/licenses.</span>
<span class="comment"> ******************************************************************************/</span>
</tt></pre>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-10811519-2");
pageTracker._trackPageview();
} catch(err) {}</script>

</body>

<p><br><address><small>
Last updated: Mon Mar 21 10:51:08 EDT 2016.
</small></address>

</html>
